package parser

import (
	"crawler/engine"
	"regexp"
)

var (
	cityListReg = regexp.MustCompile(`<a href="(http://www.zhenai.com/zhenghun/\w+)"[^>]*>([^<]+)</a>`)
)

// 解析城市列表
func ParseCityList(contents []byte, _ string) engine.ParseResult {
	matches := cityListReg.FindAllSubmatch(contents, -1)
	result := engine.ParseResult{}
	for _, m := range matches {
		result.Requests = append(result.Requests, engine.Request{
			Url:        string(m[1]),
			ParserFunc: ParseCity,
		})
	}
	return result
}
